<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>首页</title>
		<link rel="stylesheet" type="text/css" href="jquery.mobile-1.4.5.min.css" />
		<script src="js/jq.js"></script>
		<script src="js/jquery.mobile-1.4.5.min.js"></script>
		<script src="js/vendor/jquery.ui.widget.js"></script>
		<script src="js/jquery.iframe-transport.js"></script>
		<script src="js/jquery.fileupload.js"></script>
	</head>
<body>
<div data-role="page" data-theme="a">

	  <div data-role="header">
	    <h1>分享</h1>
	  </div>

	  <div data-role="content">
		    <form action="" onsubmit="return false;" id="form_page">
				  <label >产品链接:</label>
				  <input type="text" name="url"  />
				  <label >标题:</label>
				  <input type="text" name="title"  />
				  <label >描述:</label>
				  <textarea type="text"  name="desc"></textarea>
				  <label >分享图片:</label>
				  <input type="text" name="shareimg"  />
				  <label >分享链接:</label>
				  <input type="text" name="shareurl"  />
				  <input type="submit" id="save" data-inline="true" value="保存">
				  <button id="down" data-inline="true">下载</button>
				  <button id="up" data-inline="true">上传</button>
				  <input class="" accept=".csv" name="share" type="file" id="upd_files" />
			</form>
	  </div>
	<script>
		// $("#up").click(function(){
		// 	 $("#upd_files").trigger("click");
		// });
		$("#upd_files").fileupload({  
		        url: "./api/getShareCsv.php",  
		        sequentialUploads: true  
		}).bind('fileuploadsend',function(e, data){

		}).bind('fileuploaddone', function (e, data) {

		      console.log(data.result);
		       
		});
		$("#save").click(function(){
			
			$.ajax({
				url : './api/setShareXml.php',
				dataType : 'json', 
				type : 'post',
				data : $("#form_page").serialize(),
			}).done(function(data){
				console.log(data);
				if (data.code === 0) {
					window.location.reload();
				}
			});
		});
		$("#down").click(function(){
			
			$.ajax({
				url : './api/getShareJs.php',
				dataType : 'json', 
				type : 'get',
			}).done(function(data){
				if (data.code === 0) {
					window.location.reload();
				}
			});
		});
	</script>

</div>
</body>
</html>